package com.mew.user.controller;


import com.mew.common.dc.db.PlayRecordService;
import com.mew.common.entity.record.DownRecord;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
public class CommonController {

    @Autowired
    private PlayRecordService playRecordService;


    @GetMapping("/common/down/{uid}/{game}/{dtype}")
    @ResponseBody
    public Integer downloadGme(@PathVariable("uid") long userId, @PathVariable("game") int game,  @PathVariable("dtype") byte dtype){
        try {
            DownRecord record = DownRecord.builder().userId(userId).gameId(game).downType((int) dtype).build();
            log.info("down info {}", record);
            playRecordService.insertDownRecord(record);
            return 1;
        }catch (Exception e){
            log.error("", e);
            return 1;
        }

    }

}
